Ext.define('DCApp.view.relic.Detail', {
    extend: 'DCApp.view.Detail',
    alias: 'widget.relicdetail',
    
    requires: ['DCApp.ux.ComboTree'],
    bind: {
        title: '文物 - 【{theRelic.objId}】'
    },
    
    componentCls: 'relic-detail',
    bodyPadding: 0,
    
    controller: 'relicdetail',
    viewModel: {
        type: 'relicdetail'
    },
    
    tbar: ['->',{
        text: '上一条',
        handler: 'onPrev'
    },{
        text: '下一条',
        handler: 'onNext'
    },{
        text: '保存',
        handler: 'onSaveClick'
    },{
        text: '返回',
        handler: 'onBackClick'
    }],
    afterRender: function(ct, position) {
    	var imgpanel = this.down('imgpanel');
    	if(imgpanel){
	    	var tb = imgpanel.down('toolbar[dock=top]');
	    	tb.insert(1,[{
	    		text:'插入'
	    	}]);
    	}
    	var attachpanel = this.down('attachpanel');
    	if (attachpanel) {
	    	var tb = attachpanel.down('toolbar[dock=top]');
	    	tb.insert(1,[{
	    		text:'插入'
	    	}]);
    	}
    	this.callParent();
    },
    items: [{
        id:'panel0',
    	listeners: {
		  render: function(p){
			p = p.getEl();
			var me= this.up();
			me.h0=p.getHeight();
		    p.on('scroll', function(e, t){
		    	me.onscroll(t.scrollTop,t.clientHeight);
		    }, p);
		  }
		},
    	title: 'Panel 0',
        flex: 2,
        frame: false,
        xtype: 'container',
        layout: 'anchor',
        style: {
            overflow: 'auto'
        },
        items: [
        							{
							title : '文物信息',
							margin : '0 0 10 0',
							cls : 'nav_pos',
							reference : 'form',
							bodyPadding : 10,
							fieldDefaults : {
								labelAlign : 'right',
								labelWidth : 100,
								padding : 3
							},
							defaults : {
								anchor : '100%'
							},
							xtype: 'form',
                    		items: [
//	                    		{
//			                        xtype: 'displayfield',
//	                    			fieldLabel: '文物(ID)',
//			                        allowBlank: false,
//			                        bind: '{theRelic.objId}',
//			                        publishes: ['value']
//			                    },
			                    {
			                        xtype: 'container',
			                        layout: 'hbox',
			                        combineErrors: true,
			                        defaultType: 'textfield',
			                        items: [
			                        	{
			                            	flex: 1,
			                            	xtype: 'textfield',
			                        		fieldLabel: '作者(窑口)',
			                        		allowBlank: false,
			                        		bind: '{theRelic.objAuthor}',
			                        		publishes: ['value']
			                        	},
			                        	{
			                            	flex: 1,
			                            	emptyText: '文物分类',
			                        		fieldLabel: '分类',
			                        		xtype: 'combotree',
			                        		bind: '{theRelic.classa}',
					                        publishes: ['value'],
				                			storeUrl : 'resources/tree_check.json',
				                			cascade : 'child',
				                			checkModel:'single',
				                			width : 270,
				                			rootId : '1',
				                			rootText : 'DRP',
				                			treeNodeParameter : ''
			                        	}
			                        ]
			                    },
			                    {
			                        xtype: 'container',
			                        layout: 'hbox',
			                        combineErrors: true,
			                        defaultType: 'textfield',
			                        items:[
			                        	{
			                        		flex: 1,
					                        xtype: 'textfield',
					                        fieldLabel: '文物编号',
					                        allowBlank: false,
					                        bind: '{theRelic.objNo}',
					                        publishes: ['value']
					                    },
					                    {
					                    	flex: 1,
					                        xtype: 'textfield',
					                        fieldLabel: '文物名称',
					                        allowBlank: false,
					                        bind: '{theRelic.objName}',
					                        publishes: ['value']
					                    }		                        
			                        ]
			                    },
			                    {
			                    	xtype: 'container',
			                    	layout: 'hbox',
			                    	combineErrors: true,
			                    	defaultType: 'textfield',
			                    	items: [
			                    		{
			                    			flex: 1,
						                	xtype: 'textfield',
					                        fieldLabel: '级别',
					                        allowBlank: false,
					                        bind: '{theRelic.grade}',
					                        publishes: ['value']
					                    },
					                    {
					                    	flex: 1,
					                        xtype: 'textfield',
					                        fieldLabel: '文物年代',
					                        bind: '{theRelic.generateEra}',
					                        publishes: ['value'],
					                        xtype: 'combotree',
				                			storeUrl : 'resources/tree_single.json',
				                			cascade : 'child',
				                			checkModel:'single',
				                			width : 270,
				                			rootId : '1',
				                			rootText : 'DRP',
				                			treeNodeParameter : ''
					                    }
			                    	]
			                    },
			                    {		                    	
			                    	xtype: 'container',
			                    	layout: 'hbox',
			                    	combineErrors: true,
			                    	defaultType: 'textfield',
			                    	items: [
					                    {
					                    	flex: 1,
					                        xtype: 'textfield',
					                        fieldLabel: '起始年代',
					                        allowBlank: false,
					                        bind: '{theRelic.eraBegin}',
					                        publishes: ['value']
					                    },
					                    {
					                    	flex: 1,
					                        xtype: 'textfield',
					                        fieldLabel: '终止年代',
					                        allowBlank: false,
					                        bind: '{theRelic.eraEnd}',
					                        publishes: ['value']
					                    }
			                    	]
			                    },
			                    {		                    	
			                    	xtype: 'container',
			                    	layout: 'hbox',
			                    	combineErrors: true,
			                    	defaultType: 'textfield',
			                    	items: [
					                    {
					                    	flex: 1,
					                        xtype: 'textfield',
					                        fieldLabel: '备注',
					                        allowBlank: false,
					                        bind: '{theRelic.note}',
					                        publishes: ['value']
					                    },
					                    {
					                    	flex: 1,
					                        xtype: 'textfield',
					                        fieldLabel: '关键词',
					                        allowBlank: false,
					                        bind: '{theRelic.note}',
					                        publishes: ['value']
					                    }
			                    	]
			                    },
			                    {		                    	
			                    	xtype: 'container',
			                    	layout: 'hbox',
			                    	combineErrors: true,
			                    	defaultType: 'textfield',
			                    	items: [
					                    {
					                    	flex: 1,
					                        xtype: 'textfield',
					                        fieldLabel: '撰稿人',
					                        allowBlank: false,
					                        bind: '{theRelic.author}',
					                        publishes: ['value']
					                    },
					                    {
					                    	flex: 1,
					                        xtype: 'textfield',
					                        fieldLabel: '展出地点',
					                        allowBlank: false,
					                        bind: '{theRelic.showLocation}',
					                        publishes: ['value']
					                    }
			                    	]
			                    },
			                    {		                    	
			                    	xtype: 'container',
			                    	layout: 'hbox',
			                    	combineErrors: true,
			                    	defaultType: 'textfield',			                    	
			                    	items: [
					                    {
					                    	flex: 1,
					                        xtype: 'datefield',
					                        fieldLabel: '展出起始时间',
					                        allowBlank: false,
					                        format: 'Y-m-d',
					                        bind: '{theRelic.showFrom}',
					                        publishes: ['value']
					                    },
					                    {
					                    	flex: 1,
					                        xtype: 'datefield',
					                        fieldLabel: '展出截止时间',
					                        allowBlank: false,
					                        format: 'Y-m-d',
					                        bind: '{theRelic.showTo}',
					                        publishes: ['value']
					                    }
			                    	]
			                    },
			                    {		                    	
			                    	xtype: 'container',
			                    	layout: 'hbox',
			                    	combineErrors: true,
			                    	defaultType: 'textfield',
			                    	items: [
					                    {
					                    	flex: 1,
					                        xtype: 'textfield',
					                        fieldLabel: '公元纪年',
					                        allowBlank: false,
					                        bind: '{theRelic.era}',
					                        publishes: ['value']
					                    },
					                    {
					                    	flex: 1,
					                        xtype: 'textfield',
					                        fieldLabel: '材质',
					                        allowBlank: false,
					                        bind: '{theRelic.material}',
					                        publishes: ['value']
					                    }
			                    	]
			                    },
			                    {		                    	
			                    	xtype: 'container',
			                    	layout: 'hbox',
			                    	combineErrors: true,
			                    	defaultType: 'textfield',
			                    	items: [
					                    {
					                    	flex: 1,
					                        xtype: 'textfield',
					                        fieldLabel: '用色方式',
					                        allowBlank: false,
					                        bind: '{theRelic.colorMode}',
					                        publishes: ['value']
					                    },
					                    {
					                    	flex: 1,
					                        xtype: 'textfield',
					                        fieldLabel: '尺寸',
					                        allowBlank: false,
					                        bind: '{theRelic.objsize}',
					                        publishes: ['value']
					                    }
			                    	]
			                    },
			                    {
			                        xtype: 'container',
			                        layout: 'hbox',	
			                        items: [
			                        	{
			                        		flex: 4,
									        xtype: 'filefield',
									        name: 'file1',
									        fieldLabel: '上传',
									        emptyText : '请选择文件...',
									        buttonText: '选择文件'
									    },
									    {
									    	flex: 1,
									    	xtype: 'button',
									    	text: '上传',
				          					handler: 'onUploadRelic'
									    }
			                		]
				                },
				                {
				            		xtype: 'htmleditor',
				            		bind: '{theRelic.description}',
				            		publishes: ['value'],
				            		fieldLabel: '正文'                    		                    		
				               	}
		                    ]            
						},
						{
							title : '相关影像',
							margin : '0 0 10 0',
							cls : 'nav_pos',
							layout : 'fit',
							items : [
								{
									bind: '{theRelic.images}',
			                    	xtype:'imgpanel',
			                    	btns:['关联','删除']
								}
							]
						},
						{
							title : '相关论文',
							margin : '0 0 10 0',
							cls : 'nav_pos',
							layout : 'fit',
							items : [
								{
								 bind: '{theRelic.theses}',
								 xtype : 'thesislist',
								 plugins: null,
								 tbar: ['->',{
								        text: '关联',
								        handler: 'onRelThesis'
								    },{
								        text: '删除',
								        handler: 'onDelThesis'
								    }]
								}
							]							
						},
						{
							title : '相关文稿',
							margin : '0 0 10 0',
							cls : 'nav_pos',
							layout : 'fit',
							items : [
								{
									bind: '{theRelic.docs}',
									xtype : 'doclist',
									plugins: null,
								 	tbar: ['->',{
								        text: '关联',
								        handler: 'onRelDoc'
								    },{
								        text: '删除',
								        handler: 'onDelDoc'
								    }]
								}
							]							
						}
        
        
        
		]
    }]
});
